package com.mj.security.freemarker;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.servlet.view.freemarker.FreeMarkerView;

import com.mj.util.Constants;
/**
 * 自定义Freemarker的View
 *@ClassName:MyFreeMarkerView.java
 *@author MJ009
 *@date 2017年6月9日
 *@Description TODO
 *
 */
public class MyFreeMarkerView extends FreeMarkerView {
	 @Override
	 protected void exposeHelpers(Map<String, Object> model,
	         HttpServletRequest request) throws Exception {
	  String scheme = request.getScheme();
	  String serverName = request.getServerName();
	  int port = request.getServerPort();
	  String path = request.getContextPath();
	  String basePath = scheme + "://" + serverName + ":" + port + path;
	  model.put(Constants.CONTEXT_PATH, basePath);
	  super.exposeHelpers(model, request);
	 }
}
